from plugins.pman import PMan
from src.config import Config

class InvisibleHand:

    def __init__(self):
        self.config = Config()
        self.pman = PMan(self.config)
        self.pman.load_plugins()

    def get_plugins(self):
        return [plugin.to_json() for plugin in self.pman.plugins]

    def get_plugin_items(self, id):
        plugin = self.pman.get_plugin_by_id(id)
        items = plugin.get_items()
        result = plugin.to_json()
        result["items"] = items
        return result

    def do_plugin_action(self, id, action, uinput):
        plugin = self.pman.get_plugin_by_id(id)
        return plugin.do_action(action, uinput)
    

